<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <link rel="stylesheet" href="/css/manage_goods.css">
    <link rel="stylesheet" href="/css/normalize.css">
    <link rel="stylesheet" href="/css/bootstrap.css">
    <style>
        body {
            background-color: #ededed;
        }
    </style>
    <script type="text/javascript">
        //修改订单
        function updateOrder(orderid,status){
            //执行servlet请求
            window.location.href="/myorder?m=updateOrder&orderid="+orderid+"&status="+status;
        }

        //取消订单
        function cancelOrder(orderid){
            var f= confirm("您确定要取消？");
            if(f) {
                //执行servlet请求
                window.location.href = "/myorder?m=updateOrder&orderid=" + orderid + "&status=5";
            }
        }


    </script>
</head>

<body>
<jsp:include page="components/header.jsp"></jsp:include>
<div class="box"></div>
<div class="container">
   <jsp:include page="components/sidebar.jsp"></jsp:include>
    <!--    内容-->
    <div class="content">
        <div class="header">
            <div class="title">订单管理</div>
            <div class="hr"></div>
        </div>
        <div class="details">
            <table>
                <thead>
                <tr class="table-header">
                    <th>订单编号</th>
                    <th>创建时间</th>
                    <th>商品信息</th>
                    <th>总金额</th>
                    <th>订单状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody class="table-body">
                <c:forEach var="order" items="${orderList}">
                    <tr>
                        <td rowspan="${order.detailVoList.size()}">${order.toNumber}</td>
                        <td rowspan="${order.detailVoList.size()}">
                                ${order.toCreateTime}
                        </td>
                        <td>
                            <img src="${order.detailVoList.get(0).tpFileName}" alt="" class="img">
                                ${order.detailVoList.get(0).tpName}
                        </td>
                        <td rowspan="${order.detailVoList.size()}">${order.toCost}</td>
                        <td rowspan="${order.detailVoList.size()}">
                            <c:choose>
                                <c:when test="${order.toStatus == 1}">
                                    未支付
                                </c:when>
                                <c:when test="${order.toStatus == 2}">
                                    已支付
                                </c:when>
                                <c:when test="${order.toStatus == 3}">
                                    已发货
                                </c:when>
                                <c:when test="${order.toStatus == 4}">
                                    已完成
                                </c:when>
                                <c:when test="${order.toStatus == 5}">
                                    已取消
                                </c:when>
                                <c:otherwise>
                                    其他状态
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td rowspan="${order.detailVoList.size()}">
                            <c:choose>
                                <c:when test="${order.toStatus == 1}">
                                    <input type="button" value="付款" class="check-button" onclick="updateOrder('${order.toNumber}',2)">
                                    <input type="button" value="取消" class="check-button" onclick="cancelOrder('${order.toNumber}',5)">
                                </c:when>
                                <c:when test="${order.toStatus == 2}">
                                    <input type="button" value="发货" class="check-button" onclick="updateOrder('${order.toNumber}',3)">
                                    <input type="button" value="取消" class="check-button" onclick="cancelOrder('${order.toNumber}',5)">
                                </c:when>
                                <c:when test="${order.toStatus == 3}">
                                    <input type="button" value="确认收货" class="check-button" onclick="updateOrder('${order.toNumber}',4)">
                                    <input type="button" value="取消" class="check-button" onclick="cancelOrder('${order.toNumber}',5)">
                                </c:when>
                            </c:choose>
                        </td>
                    </tr>
                    <c:forEach var="details" items="${order.detailVoList}" begin="1">
                        <tr>
                            <td>
                                <img src="${details.tpFileName}" alt="" class="img">
                                    ${details.tpName}
                            </td>

                        </tr>
                    </c:forEach>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<iframe name="footer_iframe" onload="this.height=this.contentWindow.document.body.scrollHeight" width=100% src="../components/footer.html" frameborder=0 scrolling="no"></iframe>
</body>

</html>